package org.yourscrum.domain;

import javax.persistence.Entity;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.roo.addon.plural.RooPlural;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Set;
import java.util.HashSet;
import javax.persistence.OneToMany;
import javax.persistence.CascadeType;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;

@Entity
@RooEntity
@RooJavaBean
@RooToString
@RooPlural(value = "stories")
public class Story {

    @NotNull
    @Size(min = 1)
    private String description;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "story")
    private Set<Task> tasks = new HashSet<Task>();

    @NotNull
    @ManyToOne
    @JoinColumn
    private Theme theme;

    private Integer estimate;

    @OneToMany(cascade = CascadeType.ALL)
    private Set<Comment> comments = new HashSet<Comment>();
}
